/** 
 * File-Name:SimpleParser.java
 *
 * Created on 2011-4-16 下午04:09:17
 * 
 * @author: Neo (neolimeng@gmail.com)
 * Software Engineering Institute, Peking University, China
 * 
 * Copyright (c) 2009, Peking University
 * 
 *
 */
package org.neocrawler.parser;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.neocrawler.crawler.CrawlerManager;
import org.neocrawler.entity.WebContent;

/**
 * Description:A simple parser. The seed URLs are store in a txt file, one URL
 * per line.
 * 
 * @author: Neo (neolimeng@gmail.com) Software Engineering Institute, Peking
 *          University, China
 * @version 1.0 2011-4-16 下午04:09:17
 */
public class SimpleParser implements IParser {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.neocrawler.parser.IParser#getInitialSeeds()
	 */
	@Override
	public List<WebContent> getInitialSeeds() {
		List<WebContent> webContents = new ArrayList<WebContent>();

		try {
			File file = new File(CrawlerManager.getConfiguration()
					.getSeedPath());
			List seedUrlList = FileUtils.readLines(file);
			for (Object line : seedUrlList) {
				WebContent webContent = new WebContent();
				webContent.setType(TYPE_SEED);
				webContent.setUrl(line.toString());
				webContents.add(webContent);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return webContents;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.neocrawler.parser.IParser#parse(org.neocrawler.entity.WebContent,
	 * java.lang.String)
	 */
	@Override
	public List<WebContent> parse(WebContent webContent, String webPage) {
		return null;
	}

	/**
	 * Description:
	 * 
	 * @param args
	 *            void
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
